<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var ligergrid = null;
function queryHangConditions(){
	var templateId = $("#templateId").val();
	ligergrid = $("#maingrid").ligerGrid({
        columns: [
		  { display: '相对行数', name: 'relRowNum', width:'8%',render:function(row){
        	  return '第' + row.relRowNum + '行';
          }},
          { display: '统计信息集', name: 'chineseName', width:'13%'},
          { display: '统计信息项', name: 'itemChineseName', width:'13%'},
          { display: '关系运算符', name: 'relaOperator',width:'10%',render:function(row){
			  var relaOperatorMap = {'1':'等于','2':'大于等于','3':'小于等于','4':'大于','5':'小于','6':'不等于','7':'包含','8':'按左侧匹配','9':'按右侧匹配'};
        	  return relaOperatorMap[row.relaOperator + ''];
          }},
          { display: '条件值', name: 'conditionVal', width:'17%'},
          { display: '是否优先查询', name: 'comboType',width:'10%',render:function(row){
			  var comboTypeMap = {'null':'否','0':'否','1':'左括号','2':'右括号'};
        	  return comboTypeMap[row.comboType + ''];
          }},
          { display: '并且/或者', name: 'logicOperator',width:'10%',render:function(row){
			  var logicOperatorMap = {'null':'空','0':'空','1':'并且','2':'或者'};
        	  return logicOperatorMap[row.logicOperator + ''];
          }},
          { display: '顺序', name: 'orderId', width:'8%'},
          {
              display: '操作', isAllowHide: false,width:'10%',
              render: function (row)
              {
            	  var myDate = new Date();
            	  var myYear = myDate.getFullYear();
                  var html = '';
                	  html += '<a href="#" onclick="editHang(\'' + row.conditionId + '\')" class="update-btn">编辑</a>||';
                	  html += '<a href="#" onclick="deleteHang(\'' + row.conditionId + '\')" class="update-btn">删除</a>';

                  return String.format(html,row.annualId);
              }
          }

        ],
        url: '${ctx}/reportTemplateConditionsController/getHangCondByTemplateId/'+templateId,
        pageSize: 10, sortName: 'orderId',
        width: '99%', height: '96%', rownumbers:true,
        pageParmName:'pageNum',
        pagesizeParmName:'pageSize',
        sortnameParmName:'sortname',
        sortorderParmName:'sortorder',
        alternatingRow:true,
    });
}

function newHang(){
	var templateId = $("#templateId").val();
	$.layer({
	    type: 2,
	    maxmin: true,
	    shadeClose: true,
	    title: '新增行条件',
	    shade: [0.1,'#000000'],
	    shift:'top',
	    offset: [($(window).height() / 10)+'px',''],
	    area: ['500px', '400px'],
	    iframe: {src: '${ctx}/reportTemplateConditionsController/preHangCreate/'+templateId},
	    end: function(index){
	    	ligergrid.loadData();
	    }
	}); 
}

function editHang(conditionId){
	var templateId = $("#templateId").val();
	$.layer({
	    type: 2,
	    maxmin: true,
	    shadeClose: true,
	    title: '修改行条件',
	    shade: [0.1,'#000000'],
	    shift:'top',
	    offset: [($(window).height() / 10)+'px',''],
	    area: ['500px', '400px'],
	    iframe: {src: '${ctx}/reportTemplateConditionsController/preConditionUpdate/'+conditionId+"/"+templateId+"/2"},
	    end: function(index){
	    	ligergrid.loadData();
	    }
	}); 
}

function deleteHang(conditionId){
	layer.confirm('是否删除',function(){
		$.ajax({
			url:'${ctx}/reportTemplateConditionsController/deleteTemplateConditionById/'+conditionId,
			type:'POST',
			cache:false,
			success:function(data){
				if(data == 'success'){
					layer.alert('操作成功',9);
					ligergrid.loadData();
				}else{
					layer.alert('操作失败');
				}
			}
		});
	});
}
</script>
</head>
<body>
</body>
</html>